package com.trkj.controller.lzs;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojo.Salary;
import com.trkj.pojo.SalaryAccount;
import com.trkj.pojo.SocialSecurity;
import com.trkj.service.lzs.SocialAccountService;
import com.trkj.service.lzs.SocialLeixingService;
import com.trkj.service.lzs.SocialSecurityService;
import com.trkj.vo.Result;
import com.trkj.vo.Result2;
import com.trkj.vo.ShebaoVo;
import com.trkj.vo.payVO;
@Controller
public class SocialSecurityController {
	//查询所有
	   @Autowired
	   private   SocialSecurityService socialSecurityService;
	 //查询所有
	   @Autowired
	   private  SocialLeixingService SocialLeixingService;
	   @Autowired
	    private   SocialAccountService  SocialAccountService;
		@RequestMapping("lzs_SocialSecurityfind")
		@ResponseBody
		public List<SocialSecurity> socialSecurityfind(){
			List<SocialSecurity> list = socialSecurityService.SocialSecurityfindAll();
			list.forEach(e->{
				System.err.println("aaaaa"+e);
			});
			return list;
		}
		//添加
		@RequestMapping("lzs_socialSecuritytianjia")
		@ResponseBody
		public void SocialSecuritytianjia(Timestamp securityCretordate ,Timestamp securityEnddate,String securityName,BigDecimal securityNumberEmployees,String securityPerson
				,String securityRemark,Timestamp securityStartdate,Timestamp securityUpdatedate ){
			socialSecurityService.SocialSecuritytj(securityCretordate, securityEnddate, securityName, securityNumberEmployees, securityPerson, securityRemark, securityStartdate, securityUpdatedate);
		}
		/*修改
		*/
		@RequestMapping("lzs_socialSecurityxiugai")
		@ResponseBody  
		public  Result2  socialSecurityxiugai( long securityId,Timestamp securityCretordate ,Timestamp securityEnddate,String securityName,BigDecimal securityNumberEmployees,String securityPerson
				,String securityRemark,Timestamp securityStartdate,Timestamp securityUpdatedate) {
			try {
				socialSecurityService.lzs_SocialSecurity(securityId, securityCretordate, securityEnddate, securityName, securityNumberEmployees, securityPerson, securityRemark, securityStartdate, securityUpdatedate);
				return Result2.SUCCESS;
			} catch (Exception e) {
					e.printStackTrace();
				return Result2.failure(e.getMessage());
			}
			
		}
		
		@RequestMapping("lzs_socialSecuritybj")
		@ResponseBody  
		 public SocialSecurity chunq(Long securityId) {
	    	 return socialSecurityService.chun(securityId);
	     }

		//模糊查询shuoy
			@RequestMapping("lzs_socialSecuritychaxun")
			@ResponseBody
			public  List<SocialSecurity> Query(String text){
				System.out.println(text);
				return (List<SocialSecurity>) socialSecurityService.queryByName(text);
			}
			
		//多表查询
	/*	@RequestMapping("lzs_findAllduososocialSecurityen")
			@ResponseBody
			public List<ShebaoVo> duobiao(){
				return 	 socialSecurityService.selcet_SalaryAccount();
		}*/
/*
			/**
			 * 查
			 * @return
			 */
	@RequestMapping("lzs_findAllduososocialSecurityen")
			@ResponseBody
			public List<ShebaoVo> selcet_SocialSecurity(){
				try {
					return socialSecurityService.selcet_social_table();
				} catch (Exception e) {
					e.printStackTrace();
					return null;
				}
			}

		/*	//多表增加
			@RequestMapping("lzs_findAllduozjsocialSecurity")
			@ResponseBody
			public Result add_SalaryAccount(SocialSecurity s ,Long securityId,Long socialId ,Long sblxId ){
			s.setAccountCreatordate(new Timestamp(new Date().getTime()));
			try {
				System.err.println(socialId);
				System.err.println(sblxId);
				socialSecurityService.add_SalaryAccount(s,  socialId,sblxId);
			return Result.SUCCESS;
			} catch (Exception e) {
			e.printStackTrace();
			return Result.failure(e.getMessage());
			}
			}*/
			
			/**
			 * 增
			 * @return
			 */
			@PostMapping("lzs_findAllduozjsocialSecurity")
			@ResponseBody
			public Result add_SocialSecurity(SocialSecurity Social,Long socialId  ,Long sblxId){
				try {
					socialSecurityService.add_SocialSecurity(Social, socialId,sblxId);
					return Result.SUCCESS;
				} catch (Exception e) {
					e.printStackTrace();
					return Result.failure(e.getMessage());
				}
			}
			
			
			
}
